import Vue from 'vue'
import Vuex from 'vuex'
import lockr from 'lockr'
import {enf} from '../data'
//解密函数
Vue.use(Vuex)

const store = new Vuex.Store({
  // 定义状态
    state: {
        shiro:false,
        shiroitem:{
          admin:false,//超管
          manager:false,//店长
          kefu:false,//客服
          caiwu:false,//财务
        },
        //全局权限管理变量 true:超级管理员 false:店长
        //后期如果为多家权限系统,可以把shiro设置为对象,在对象里对单个权限做鉴别
        TOPshopID:lockr.get('TOPshopID')||'',
        TOPshopName:lockr.get('TOPshopName')||'',
        TOPshop:[],//用来存所有店铺
        //店铺名称
        hometime:[],
        sethometime:false,
        // =================OenFileDiaLog=================
        goodkindeditclass:false,
        goodkindeditform:{},
        goodkindnew:false,
        //商品类型弹窗
        orderdetialclass:false,
        orderdetial:{},
        ordertuikuanclass:false,
        ordertuikuan:{},
        ordertuikuandialog:true,
        //订单详情弹窗
        cusdataclass:false,
        cusdata:{},
        //客户の交易记录
        shopformclass:false,
        shopform:{},
        shoplist:false,
        //修改店铺信息
        glistinfoclass:false,
        glistinfo:{},
        //商品列表页库存配置
        qiniuToken:"",

        wxconfigclass:false,
        wxconfig:{},
        wxconfignew:true,
        goodslistclass:false,
        goodslist:{},
        floorclass:false,
        floorlist:{},
        floornew:true,
        projectclass:false,
        project:{},
        projectnew:true,
        flootgoodlistclass:false,
        floorgoodlist:{},
        flootgoodlistclass2:false,
        floorgoodlist2:{},
        floor:true,
        //广告配置
        //进销存
        createpandianclass:false,
        createpandian:true,
        createrukuclass:false,
        createruku:true,
        createrukuclass2:false,
        createruku2:true,
        creatediaohuoclass:false,
        creatediaohuo:true,
        createbaosunclass:false,
        createbaosun:true,
        dinghuoclass:false,
        dinghuo:true,
        xiaoshouclass:false,
        xiaoshou:true,

        jxcdetial:0,
        //进销存模块内容
        //优惠券管理
        coulistclass:false,
        coulistnew:true,
        coulist:{},
        closecoulistdialog:true,
        //优惠券管理
        coutimeclass:false,
        coutime:{},
        coutimedialog:true,
        //抢劵
        coushareclass:false,
        coushare:{},
        cousharedialog:true,
        couruleclass:false,
        courule:{},
        couruleditclass:false,
        couruledit:{},
        courulesdialog:true,
        //分享活动
        coulistsclass:false
        //优惠券のdialog列表
    },
  mutations:{
    shirogetstate(state){
      state.shiroitem.admin=false//统一置否
      state.shiroitem.manager=false
      state.shiroitem.kefu=false
      state.shiroitem.caiwu=false
      var num=parseInt(enf())//此处为解密判断
      switch (num) {
        case 1://超管为1
          state.shiroitem.admin=true
          state.shiro=true
          break;
        case 0://店长为0
          state.shiroitem.manager=true
          state.TOPshopID=lockr.get('TOPshopID')
          state.TOPshopName=lockr.get('TOPshopName')
          state.shiro=false
          break;
        case 2://客服为2
          state.shiroitem.kefu=true
          state.shiro=true
          break;
        case 3://财务为3
          state.shiroitem.caiwu=true
          state.shiro=true
          break;
      
        default:
          break;
      }
    },
      ChangeGoodKindEditClass(state,change){
          if(change===undefined){
            state.goodkindeditclass=!state.goodkindeditclass
            // 如果不是编辑只执行弹窗
          }else{
            state.goodkindeditclass=!state.goodkindeditclass
            state.goodkindeditform=change
            //如果有值则是编辑，弹窗后添加内容
          }
      },
      ChangeOrderDetial(state,change){
        if(change===undefined){
          state.orderdetialclass=!state.orderdetialclass
          // 如果不是编辑只执行弹窗
        }else{
          state.orderdetialclass=!state.orderdetialclass
          state.orderdetial=change
          //如果有值则是编辑，弹窗后添加内容
        }
      },
      ChangeOrderRefund(state,change){
        if(change===undefined){
          state.ordertuikuanclass=!state.ordertuikuanclass
          // 如果不是编辑只执行弹窗
        }else{
          state.ordertuikuanclass=!state.ordertuikuanclass
          state.ordertuikuan=change
          //如果有值则是编辑，弹窗后添加内容
        }
      },
      ChangeCusData(state,change){
        if(change===undefined){
          state.cusdataclass=!state.cusdataclass
          // 如果不是编辑只执行弹窗
        }else{
          state.cusdataclass=!state.cusdataclass
          state.cusdata=change
          //如果有值则是编辑，弹窗后添加内容
        }
      },
      ChangeShopForm(state,change){
        if(change===undefined){
          state.shopformclass=!state.shopformclass
          // 如果不是编辑只执行弹窗
        }else{
          state.shopformclass=!state.shopformclass
          state.shopform=change
          //如果有值则是编辑，弹窗后添加内容
        }
      },
      ChangeConfigurationInventory(state,change){
        if(change===undefined){
          state.glistinfoclass=!state.glistinfoclass
          // 如果不是编辑只执行弹窗
        }else{
          state.glistinfoclass=!state.glistinfoclass
          state.glistinfo=change
          //如果有值则是编辑，弹窗后添加内容
        }
      },
      ChangeWxConfig(state,change){
        if(change===undefined){
          state.wxconfigclass=!state.wxconfigclass
          // 如果不是编辑只执行弹窗
        }else{
          state.wxconfigclass=!state.wxconfigclass
          state.wxconfig=change
          //如果有值则是编辑，弹窗后添加内容
        }
      },
      ChangeWxGood(state,change){
        if(change===undefined){
          state.goodslistclass=!state.goodslistclass
          // 如果不是编辑只执行弹窗
        }else{
          state.goodslistclass=!state.goodslistclass
          state.goodslist=change
          //如果有值则是编辑，弹窗后添加内容
        }
      },
      ChangeFloor(state,change){
        if(change===undefined){
          state.floorclass=!state.floorclass
          // 如果不是编辑只执行弹窗
        }else{
          state.floorclass=!state.floorclass
          state.floorlist=change
          //如果有值则是编辑，弹窗后添加内容
        }
      },
      ChangeProject(state,change){
        if(change===undefined){
          state.projectclass=!state.projectclass
          // 如果不是编辑只执行弹窗
        }else{
          state.projectclass=!state.projectclass
          state.project=change
          //如果有值则是编辑，弹窗后添加内容
        }
      },
      ChangeFloorGoodList(state,change){
        if(change===undefined){
          state.flootgoodlistclass=!state.flootgoodlistclass
          // 如果不是编辑只执行弹窗
        }else{
          state.flootgoodlistclass=!state.flootgoodlistclass
          state.floorgoodlist=change
          //如果有值则是编辑，弹窗后添加内容
        }
      },
      ChangeFloorGoodList2(state,change){
        if(change===undefined){
          state.flootgoodlistclass2=!state.flootgoodlistclass2
          // 如果不是编辑只执行弹窗
        }else{
          state.flootgoodlistclass2=!state.flootgoodlistclass2
          state.floorgoodlist2=change
          //如果有值则是编辑，弹窗后添加内容
        }
      },
      //============================================================================
      ChangeCreatePutInStorage(state,change){
          state.createrukuclass=!state.createrukuclass
      },
      ChangeCreatePutInStorage2(state,change){
          state.createrukuclass2=!state.createrukuclass2
      },
      ChangeCreateInventory(state,change){
        if(change===undefined){
          state.createpandianclass=!state.createpandianclass
          // 如果不是编辑只执行弹窗
        }else{
          state.createpandianclass=!state.createpandianclass
          state.createpandian=change
          //如果有值则是编辑，弹窗后添加内容
        }
      },
      ChangeCreateTransferCargo(state,change){
        if(change===undefined){
          state.creatediaohuoclass=!state.creatediaohuoclass
          // 如果不是编辑只执行弹窗
        }else{
          state.creatediaohuoclass=!state.creatediaohuoclass
          state.creatediaohuo=change
          //如果有值则是编辑，弹窗后添加内容
        }
      },
      ChangeCreateReportedLoss(state,change){
        if(change===undefined){
          state.createbaosunclass=!state.createbaosunclass
          // 如果不是编辑只执行弹窗
        }else{
          state.createbaosunclass=!state.createbaosunclass
          state.createbaosun=change
          //如果有值则是编辑，弹窗后添加内容
        }
      },
      ChangeCreateBooking(state,change){
        if(change===undefined){
          state.dinghuoclass=!state.dinghuoclass
          // 如果不是编辑只执行弹窗
        }else{
          state.dinghuoclass=!state.dinghuoclass
          state.createbaosun=change
          //如果有值则是编辑，弹窗后添加内容
        }
      },
      ChangeCouList(state,change){
        if(change===undefined){
          state.coulistclass=!state.coulistclass
          // 如果不是编辑只执行弹窗
        }else{
          state.coulistclass=!state.coulistclass
          state.coulist=change
          //如果有值则是编辑，弹窗后添加内容
        }
      },
      ChangeCouTime(state,change){
        if(change===undefined){
          state.coutimeclass=!state.coutimeclass
          // 如果不是编辑只执行弹窗
        }else{
          state.coutimeclass=!state.coutimeclass
          state.coutime=change
          //如果有值则是编辑，弹窗后添加内容
        }
      },
      ChangeCouShare(state,change){
        if(change===undefined){
          state.coushareclass=!state.coushareclass
          // 如果不是编辑只执行弹窗
        }else{
          state.coushareclass=!state.coushareclass
          state.coushare=change
          //如果有值则是编辑，弹窗后添加内容
        }
      },
      ChangeCouRule(state,change){
        state.couruleclass=!state.couruleclass
        state.courule=change
      },
      ChangeCouRuleEdit(state,change){
          if(change==undefined){
            return
          }
          state.couruleditclass=!state.couruleditclass
          state.couruledit=change

      },
      ChangeCouLists(state){
        state.coulistsclass=!state.coulistsclass
      }
  }
})

export default store